<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>filter</title>
  <script src="../../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <h1>价格:{{price1| moneyFilter}}</h1>
    <h1>价格:{{price2| moneyFilter("$")}}</h1>
  </div>

  <script>
    Vue.filter("moneyFilter", function (oldVal, type) {
      return `${type||"¥"}${oldVal.toFixed(2)}`
    })
    
    var vm = new Vue({
      el: "#app",
      data: {
        price1: 12.5,
        price2: 12.5
      }
    });
  </script>
</body>

</html>